import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-plugin-persistedstate'
import type { App } from 'vue'

const store = createPinia()

// 配置持久化
store.use(
  createPersistedState({
    storage: {
      getItem: (key: string) => {
        return uni.getStorageSync(key)
      },
      setItem: (key: string, value: string) => {
        uni.setStorageSync(key, value)
      }
    }
  })
)

export function setupStore(app: App) {
  app.use(store)
}

export { store }
export * from './user'
export * from './app'
export * from './chat'
